package org.scboy.common.dynamic.node.httpNode;

import org.scboy.common.annotation.ScriptNode;
import org.scboy.common.dynamic.node.BaseNode;
import org.scboy.common.request.Result;

import cn.hutool.json.JSONObject;

@ScriptNode(value="HTTP_RESPONSE_SUCCESS")
public class HttpResponseSuccessNode extends BaseNode {

	private String messageCode=null;
	
	@Override
	public void create(JSONObject object) {
		messageCode=object.getStr("messageCode");
	}

	@Override
	public Object run() {
		
		/**
		 * 测试日志
		 */
		if(this.script.isTest()) {
			this.script.appendMsg("----->开始执行："+getNodeName()+" 节点ID："+this.getId());
		}
		
		Object data=getSourceData("data", false, Object.class);
		
		Result result=Result.Success(data,messageCode);
		
		/**
		 * 测试日志
		 */
		if(this.script.isTest()) {
			this.script.appendMsg("返回值：\r\n"+entityToString(result));
		}
		return result;
	}
}
